package cn.liontalk.CompositePattern.unnormal;

import java.util.LinkedList;
import java.util.List;

public class Leader  {

    private String name;
    private List<Engineer> engineers;

    public Leader(String name) {
        this.name = name;
        this.engineers = new LinkedList<>();
    }

    public void add(Engineer engineer) {
        this.engineers.add(engineer);
    }

    public void remove(Engineer engineer) {
        this.engineers.remove(engineer);
    }

    public void display(int index) {
        for (int i = 0; i < index; i++) {
            System.out.print("----");
        }
        System.out.println("组长：" + this.name);
        engineers.forEach(engineer -> {
            engineer.display(index + 1);
        });
    }

}
